package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.JobContentMaintain;
import com.ruoyi.system.mapper.JobContentMaintainMapper;
import com.ruoyi.system.service.JobContentMaintainService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 日审核表内容维护(JobContentMaintain)表服务实现类
 *
 * @author makejava
 * @since 2022-11-23 09:20:08
 */
@Service("jobContentMaintainService")
public class JobContentMaintainServiceImpl implements JobContentMaintainService {
    @Resource
    private JobContentMaintainMapper jobContentMaintainDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public JobContentMaintain queryById(Integer id) {
        return this.jobContentMaintainDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param jobContentMaintain 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<JobContentMaintain> queryByPage(JobContentMaintain jobContentMaintain, PageRequest pageRequest) {
        long total = this.jobContentMaintainDao.count(jobContentMaintain);
        return new PageImpl<>(this.jobContentMaintainDao.queryAllByLimit(jobContentMaintain, pageRequest), pageRequest, total);
    }

    @Override
    public List<JobContentMaintain> queryAll(JobContentMaintain jobContentMaintain) {
        return jobContentMaintainDao.queryAll(jobContentMaintain);
    }

    /**
     * 新增数据
     *
     * @param jobContentMaintain 实例对象
     * @return 实例对象
     */
    @Override
    public JobContentMaintain insert(JobContentMaintain jobContentMaintain) {
        this.jobContentMaintainDao.insert(jobContentMaintain);
        return jobContentMaintain;
    }

    /**
     * 修改数据
     *
     * @param jobContentMaintain 实例对象
     * @return 实例对象
     */
    @Override
    public JobContentMaintain update(JobContentMaintain jobContentMaintain) {
        this.jobContentMaintainDao.update(jobContentMaintain);
        return this.queryById(jobContentMaintain.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.jobContentMaintainDao.deleteById(id) > 0;
    }
}
